IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_SiteAdminMapSelectOne]') AND type in (N'P', N'PC'))
	DROP PROCEDURE [dbo].[cms_sp_SiteAdminMapSelectOne]
GO
create procedure [dbo].[cms_sp_SiteAdminMapSelectOne]
(
@Id int
)
as
select 
	SiteAdminMaps.SiteAdminMapId as Id,
	parent.SiteAdminMapId as ParentNodeId,
	cast(SiteAdminMaps.NodeTreeId.GetLevel() as int) as Level,
	SiteAdminMaps.NodeTitle,
	SiteAdminMaps.NodeDescription,
	SiteAdminMaps.NodeUrl,
	SiteAdminMaps.IsSpecial,
	SiteAdminMaps.IsVisible,
	SiteAdminMaps.IsCustom	
from [dbo].[SiteAdminMaps] 
left join [dbo].[SiteAdminMaps] as parent
on parent.NodeTreeId = SiteAdminMaps.NodeTreeId.GetAncestor(1)
where SiteAdminMaps.SiteAdminMapId = @Id


GO

